<?php
    include './public/db_object.php';
    // 开启session
    session_start();
    if(isset($_POST['user'])){
        @$user = $_SESSION['user_name'];
        // 判断用户是否登录
        if(empty($user)){ 
            echo json_encode(['error'=>0]);
        }else{
            $sql = "select * from user where name='".$user."'";
            $db = new DB_object(['db_name'=>'db_shop']);
            $res = $db->l_select_one($sql);
            unset($res['pass']);
            unset($res['salt']);
            if(empty($res)){
                echo '查询用户失败';
                exit;
            }else{
                echo json_encode(['error'=>1, 'data'=>$res]);
            }
        }

    }


?>